package com.such.kit.validate.validator.impl;

import java.util.List;
import com.such.kit.validate.ValidateCommons;
import com.such.kit.validate.validator.Validator;

/**
 * @author SUCH
 * <pre>
 * 日期格式校验器
 * 
 * [参数集说明]
 * 输入内容必须符合日期格式 #[1]
 * </pre>
 */
public class DateValidator extends Validator {

	@Override
	protected boolean checkParams(List<String> params) {
		if (params.size() == 1) {
			return true;
		}
		return false;
	}

	@Override
	protected boolean verify(String value, List<String> params) {
		if (ValidateCommons.isEmpty(value)) {
			return true;
		}
		String format = params.get(0);
		value = value.replaceAll("[0-9]", "X");
		format = format.replaceAll("[a-zA-Z]", "X");
		if (value.equals(format)) {
			return true;
		}
		return false;
	}

	@Override
	protected String getVerifyMessage(List<String> params) {
		return "输入内容必须符合日期格式 #[1]";
	}

}
